Handling Entities

Entities are storage containers used to hold data. They are the physical building blocks from which XML documents are constructed. Every XML document has at least one entity that serves as the base entity for the entire document. Except for this special entity, all entities must have a name as well as a piece of data associated with the entity.

Entities must be declared before they are used, and may be internal or external, parsed or unparsed, and general or parameter. Each of these types of entities will be discussed shortly. The various entity types can only be created in certain combinations, and must follow rules (based on the entity type) as to where they are declared (defined) and where they are used:

Type Declared in Used In Always Parsed?
Internal General Internal DTD XML Doc Yes
External General External DTD XML Doc No
Internal Parameter Internal DTD Internal DTD Yes
External Parameter External DTD External DTD Yes

Entity Types

Features and Properties

Features

Properties

Entity References and CDATA

Special Characters

Reference Code Numbers for Special Characters